package com.techstar.ats;

import lombok.RequiredArgsConstructor;

import com.techstar.ats.codec.MessageDecoder;
import com.techstar.ats.codec.history.decoder.*;
import com.techstar.ats.codec.live.codec.F01MessagePollingCodec;
import com.techstar.ats.codec.live.decoder.*;
import com.techstar.ats.codec.resume.decoder.F25ResumeBeginAckDecoder;
import com.techstar.ats.codec.resume.decoder.F26ResumeEndAckDecoder;
import com.techstar.ats.codec.resume.decoder.F30ResumeDataDecoder;
import com.techstar.ats.type.Enumerated;

@RequiredArgsConstructor
public enum MessageType implements Enumerated {
	NULL(0x00, "空消息"),
	MESSAGE_POLLING(0x01, "心跳消息", F01MessagePollingCodec.INSTANCE),
	NETWORK_ALIVE_STATUS(0x02, "信息源网络状态", F02NetworkAliveStatusDecoder.INSTANCE),
	LOAD_DEVICE_STATUS(0x03, "ATS信息请求"),
	DEVICE_STATUS_BITMAP(0x04, "设备状态全体", F04DeviceStatusBitmapDecoder.INSTANCE),
	DEVICE_STATUS_CHANGE(0x05, "设备状态变化", F05DevStatusChangeDecoder.INSTANCE),
	SIGNAL_ROUTE_STATUS(0x06, "自动/人工信号模式", F06SignalRouteStatusDecoder.INSTANCE),
	DEPOT_PLAN(0x07, "出入库派班计划", F07DepotPlanDecoder.INSTANCE),
	TRAIN_RECORD(0x08, "列车报点", F08TrainRecordDecoder.INSTANCE),
	TRAIN_INDICATION_INIT(0x09, "列车信息全体", F09TrainIndicationInitDecoder.INSTANCE),
	TRAIN_INDICATION_UPDATE(0x10, "列车信息更新", F10TrainIndicationUpdateDecoder.INSTANCE),
	TRAIN_INDICATION_REMOVE(0x11, "列车信息删除", F11TrainIndicationRemoveDecoder.INSTANCE),
	REPORT_ASK(0x12, "统计信息查询"),
	GROUP_RUNNING_REPORT(0x13, "车组运行里程报告", F13GroupRunningReportDecoder.INSTANCE),
	DRIVER_DISTANCE_REPORT(0x14, "司机驾驶里程报告", F14DriverDistanceReportDecoder.INSTANCE),
	DISPATCHER_REPORT(0x15, "调度日志报告", F15DispatcherReportDecoder.INSTANCE),
	GROUP_BAK_REPORT(0x16, "存备车报告", F16GroupBakReportDecoder.INSTANCE),
	GROUP_STATUS_REPORT(0x17, "列车整备状态报告", F17GroupStatusReportDecoder.INSTANCE),
	ALARM_ASK(0x18, "事件及告警信息请求"),
	ACTION_REPORT(0x19, "操作命令", F19ActionReportDecoder.INSTANCE),
	ALARM_REPORT(0x20, "列车信息、系统事件", F20AlarmReportDecoder.INSTANCE),
	LOAD_HISTORY_TG_DATA(0x21, "历史运行图申请"),
	INUSED_SCHEDULE(0x22, "计划列车运行图消息", F22InusedScheduleDecoder.INSTANCE),
	HISTORY_SCHEDULE(0x23, "实际列车运行图消息", F23HistoryScheduleDecoder.INSTANCE),
	RESUME_ASK(0x24, "断点续传申请"),
	RESUME_BEGIN_ACK(0x25, "断点续传开始", F25ResumeBeginAckDecoder.INSTANCE),
	RESUME_END_ACK(0x26, "断点续传结束", F26ResumeEndAckDecoder.INSTANCE),
	REPORT_NACK(0x27, "查询无结果消息", F27ReportNackDecoder.INSTANCE),
	REPORT_BEGIN(0x28, "查询结果开始消息", F28ReportBeginDecoder.INSTANCE),
	REPORT_END(0x29, "查询结果结束消息", F29ReportEndDecoder.INSTANCE),
	RESUME_DATA(0x30, "断点续传数据消息", F30ResumeDataDecoder.INSTANCE),
	;

	private final int value;
	private final String literal;
	public final MessageDecoder<?> decoder;

	MessageType(int value, String literal) {
		this(value, literal, null);
	}

	public int value() {
		return value;
	}

	public String literal() {
		return this.literal;
	}

	public static MessageType valueOf(int value) {
		return Enumerated.valueOf(MessageType.class, value, NULL);
	}
}
